﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Decorator
{
    internal class FullBorder : Border
    {
        public FullBorder(Display display) : base(display)
        {
        }

        public override int GetColumns()
        {
            return 1 + this.display.GetColumns() + 1;
        }

        public override int GetRows()
        {
            return 1 + this.display.GetRows() + 1;
        }

        public override string GetRowText(int row)
        {
            if (row == 0)
            {
                return $"+{this.MakeLine('-', this.display.GetColumns())}+";
            }
            if (row == this.display.GetRows() + 1)
            {
                return $"+{this.MakeLine('-', this.display.GetColumns())}+";
            }
            return $"|{this.display.GetRowText(row - 1)}|";
        }

        private string MakeLine(char ch, int count)
        {
            var buf = new StringBuilder();
            for (var i = 0; i < count; i++)
            {
                buf.Append(ch);
            }
            return buf.ToString();
        }
    }
}
